"ctags --recurse --tag-relative \
"    --languages=-javascript,sql \
"    --exclude=.git \ "    --sort=yes --append \
"    --PHP-kinds=+cf \
"    --regex-PHP='/abstract class ([^ ]*)/\1/c/' \
"    --regex-PHP='/interface ([^ ]*)/\1/c/' \
"    --regex-PHP='/(public |static |abstract |protected |private )+function ([^ (]*)/\2/f/' \
"    -f \"${TAG_FILE}\" \
"    $LaravelPath

fu! CTags_c_generate()
    execute "!mkdir -p ~/ctags/c"
    let ctags_file_path = "~/ctags/c/" . tolower(substitute(getcwd(), "/", "_", "g"))
    let cmd="!ctags -f " . ctags_file_path . " --recurse --exclude=\"\.svn\" --exclude=\"\.git\" --totals=yes --tag-relative=yes -R ." 
    execute cmd
endfunction

fu! CTags_PHP_generate()
    execute "!mkdir -p ~/ctags/php"
    let ctags_file_path = "~/ctags/php/" . tolower(substitute(getcwd(), "/", "_", "g"))
    let cmd="!ctags -f " . ctags_file_path
    let cmd.=" -h \".php\" -R  "
    let cmd.="--recurse " 
    let cmd.="--exclude=\"\.svn\" "
    let cmd.="--exclude=\"\.git\" "
    let cmd.="--totals=yes "
    let cmd.="--tag-relative=yes "
    let cmd.="--PHP-kinds=+cf "
    let cmd.="--regex-PHP='/abstract class ([^ ]*)//c/' "
    let cmd.="--regex-PHP='/interface ([^ ]*)//c/' "
    let cmd.="--regex-PHP='/(public |static |abstract |protected |private )+function ([^ (]*)//f/'"
    "echom cmd
    execute cmd
endfunction


fu! CTags_lua_generate()
    execute "!mkdir -p ~/ctags/lua"
    let ctags_file_path = "~/ctags/lua/" . tolower(substitute(getcwd(), "/", "_", "g"))
    let cmd = "!ctags -f " . ctags_file_path ." --recurse --exclude=.svn --exclude=.git --langdef=MYLUA --langmap='MYLUA:.lua' --regex-MYLUA='/^local[ \\t]+([a-zA-Z0-9_]+)[ \\t]*=[ \\t]*\\{/\\1/v,var/' --regex-MYLUA='/[ \\t]*([a-zA-Z0-9_]+)[ \\t]*=[ \\t]*function[ \\t]*\\(/\\1/f,function/' --regex-MYLUA='/function[ \\t]+([a-zA-Z0-9_]+)[\\.:]([a-zA-Z0-9_]+)[ \\t]*\\(/\\2/f,function/' --langdef=PROTO --langmap=PROTO:.proto --regex-PROTO='/^[ \\t]*message[ \\t]+([a-zA-Z0-9_\\.]+)/\\1/m,message/' --regex-PROTO='/^[ \\t]*(required|repeated|optional)[ \\t]+[a-zA-Z0-9_\\.]+[ \\t]+([a-zA-Z0-9_]+)[ \\t]*=/\\2/f,field/' -R ."

    "echom cmd
    execute cmd
endfunction

fu! CTags_js_generate()
    execute "!mkdir -p ~/ctags/js"
    let ctags_file_path = "~/ctags/js/" . tolower(substitute(getcwd(), "/", "_", "g"))
    let cmd = "!ctags -f " . ctags_file_path . " --recurse --tag-relative -R . "
    let cmd .= "--langmap='javascript:.js.es6.es.jsx--javascript-kinds=-c-f-m-p-v' "
    let cmd .= "--regex-javascript='/^[ \\t]*(var|let|const)[ \\t]+([A-Za-z0-9_$]+)[ \\t]*=[ \\t]*\\[/\\2/A,Array,Arrays/' "
    let cmd .= "--regex-javascript='/^[ \\t]*(var|let|const)[ \\t]+([A-Z][A-Za-z0-9_$]+)[ \\t]*=[ \\t]*function/\\2/C,Class,Classes/--regex-javascript=/^[ \\t]*class[ \\t]+([A-Za-z0-9_$]+)/\\1/C,Class,Classes/' "
    let cmd .= "--regex-javascript='/^[ \\t]*export[ \\t]?({[ \\t]*)*([A-Za-z0-9_\\*]*[ \\t]as[ \\t])([A-Za-z0-9_]+)/\\3/E,Export,Exports/--regex-javascript=/^[ \\t]*export[ \\t]?({[ \\t]*)*([A-Za-z0-9_\\*]*[ \\t]as[ \\t])*([A-Za-z0-9_]+),[ \\t]*([A-Za-z0-9_\\*]*[ \\t]as[ \\t])([A-Za-z0-9_]+)/\\5/E,export,Exports/--regex-javascript=/^[ \\t]*export[ \\t]?({[ \\t]*)*([A-Za-z0-9_\\*]*[ \\t]as[ \\t])*([A-Za-z0-9_]+),[ \\t]*([A-Za-z0-9_\\*]*[ \\t]as[ \\t])*([A-Za-z0-9_]+),[ \\t]*([A-Za-z0-9_\\*]*[ \\t]as[ \\t])([A-Za-z0-9_]+)/\\7/E,Export,Exports/--regex-javascript=/^[ \\t]*export[ \\t]?(var|let|const)[ \\t]+([A_Za-z0-9_$]+)/\\2/E,Export,Exports/--regex-javascript=/^[ \\t]*export[ \\t]?(var|let|const)[ \\t]+([A_Za-z0-9_$]+)[ \\t]*[^,]+,[ \\t]*([A_Za-z0-9_$]+)/\\3/E,Export,Exports/--regex-javascript=/^[ \\t]*export[ \\t]?(var|let|const)[ \\t]+([A_Za-z0-9_$]+)[ \\t]*[^,]+,[ \\t]*([A_Za-z0-9_$]+)[ \\t]*[^,]+,[ \\t]*([A_Za-z0-9_$]+)/\\4/E,Export,Exports/' "
    let cmd .= "--regex-javascript='/^[ \\t]*function[ \\t]*([A-Za-z0-9_$]+)[ \\t\\(]/\\1/F,Function,Functions/--regex-javascript=/^[ \\t]*[\\(]function[ \\t]*([A-Za-z0-9_$]+)[ \\t\\(]/\\1/F,Function,Functions/--regex-javascript=/^[ \\t]*(var|let|const)[ \\t]+([a-z][A-Za-z0-9_$]+)[ \\t]*=[ \\t]*function[^\\*][^\\*]/\\2/F,Function,Functions/--regex-javascript=/^[ \\t]*(var|let|const)[ \\t]+([a-z][A-Za-z0-9_$]+)[ \\t]*=[ \\t]*\\([^\\*]/\\2/F,Function,Functions/' "
    let cmd .= "--regex-javascript='/^[ \\t]*function[ \\t]*\\*[ \\t]*([A-Za-z0-9_$]+)/\\1/G,Generator,Generators/--regex-javascript=/^[ \\t]*(var|let|const)[ \\t]+([a-z][A-Za-z0-9_$]+)[ \\t]*=[ \\t]*function([ \\t]*\\*)/\\2/G,Generator,Genrators/--regex-javascript=/^[ \\t]*(\\*[ \\t])([A-Za-z0-9_$]+)[ \\t]*\\(.*\\)[ \\t]*{/\\2/G,Generator,Generators/' "
    let cmd .= "--regex-javascript='/^[ \\t]*import[ \\t]?({[ \\t]*)*([A-Za-z0-9_\\*]*[ \\t]as[ \\t])([A-Za-z0-9_]+)/\\3/I,Import,Imports/--regex-javascript=/^[ \\t]*import[ \\t]?({[ \\t]*)*([A-Za-z0-9_\\*]*[ \\t]as[ \\t])*([A-Za-z0-9_]+),[ \\t]*([A-Za-z0-9_\\*]*[ \\t]as[ \\t])([A-Za-z0-9_]+)/\\5/I,Import,Imports/--regex-javascript=/^[ \\t]*import[ \\t]?({[ \\t]*)*([A-Za-z0-9_\\*]*[ \\t]as[ \\t])*([A-Za-z0-9_]+),[ \\t]*([A-Za-z0-9_\\*]*[ \\t]as[ \\t])*([A-Za-z0-9_]+),[ \\t]*([A-Za-z0-9_\\*]*[ \\t]as[ \\t])([A-Za-z0-9_]+)/\\7/I,Import,Imports/' "
    let cmd .= "--regex-javascript='/^[ \\t]*this\\.([A-Za-z0-9_$]+)[ \\t]*=.*{$/\\1/M,Method,Methods/--regex-javascript=/^[ \\t]*([A-Za-z0-9_$]+)[ \\t]*[:=][ \\t]*[\\(]*function[ \\t]*\\(/\\1/M,Method,Methods/--regex-javascript=/^[ \\t]*static[ \\t]+([A-Za-z0-9_$]+)[ \\t]*\\(/\\1/M,Method,Methods/--regex-javascript=/^[ \\t]*([A-Za-z0-9_$]+)\\(.*\\)[ \\t]*{/\\1/M,Method,Methods/' "
    let cmd .= "--regex-javascript='/^[ \\t]*(this\\.)*([A-Za-z0-9_$]+)[ \\t]*[:=].*[,;]*[^{]$/\\2/P,Property,Properties/' "
    let cmd .= "--regex-javascript='/^[ \\t]*(var|let|const)[ \\t]+([A-Za-z0-9_$]+)[ \\t]*=[ \\t]*{/\\2/O,Object,Objects/' "
    let cmd .= "--regex-javascript='/\\/\\/[ \\t]*(FIXME|TODO|BUG|NOBUG|\\?\\?\\?|\\!\\!\\!|HACK|XXX)[ \\t]*\\:*(.*)/\\1/T,Tag,Tags/' "
    let cmd .= "--regex-javascript='/^[ \\t]*(var|let|const)[ \\t]+([A-Za-z0-9_$]+)[ \\t]*=[ \\t]*[^\\[{]*;$/\\2/V,Variable,Variables/' "
    let cmd .= "--exclude=min --exclude=vendor --exclude=\\*.min.\\* --exclude=\\*.map --exclude=\\*.swp --exclude=\\*.bak --exclude=tags --exclude=node_modules --exclude=bower_components --exclude=test --exclude=__test__ --exclude=build --exclude=dist --exclude=\\*.bundle.\\*"
    "echom cmd
    execute cmd
endfunction

fu! CTags_py_generate()
    execute "!mkdir -p ~/ctags/python"
    let ctags_file_path = "~/ctags/python/" . tolower(substitute(getcwd(), "/", "_", "g"))
    let cmd="!ctags -f " . ctags_file_path
    let cmd.="  -h \".php\"  -R --fields=+l --languages=python --python-kinds=-iv "
    let cmd.="--recurse " 
    let cmd.="--exclude=\"\.svn\" "
    let cmd.="--exclude=\"\.git\" "
    let cmd.="--exclude=\"build\" "
    let cmd.="--totals=yes "
    let cmd.="--tag-relative=yes "
    "echom cmd
    execute cmd

endfunction

fu! Load_php_ctags()
    let ctags_file_path = "~/ctags/php/" . tolower(substitute(getcwd(), "/", "_", "g"))
    let cmd = "set tags=" . ctags_file_path
    echom cmd
    execute cmd
endfunction

fu! Load_js_ctags()
    let ctags_file_path = "~/ctags/js/" . tolower(substitute(getcwd(), "/", "_", "g"))
    let cmd = "set tags=" . ctags_file_path
    echom cmd
    execute cmd
endfunction

fu! Load_lua_ctags()
    let ctags_file_path = "~/ctags/lua/" . tolower(substitute(getcwd(), "/", "_", "g"))
    let cmd = "set tags=" . ctags_file_path
    echom cmd
    execute cmd
endfunction

fu! Load_c_ctags()
    let ctags_file_path = "~/ctags/c/" . tolower(substitute(getcwd(), "/", "_", "g"))
    let cmd = "set tags=" . ctags_file_path
    echom cmd
    execute cmd
endfunction

fu! Load_py_ctags()
    let ctags_file_path = "~/ctags/python/" . tolower(substitute(getcwd(), "/", "_", "g"))
    let cmd = "set tags=" . ctags_file_path
    echom cmd
    execute cmd
endfunction

fu! Load_js_ctags()
    let ctags_file_path = "~/ctags/js/" . tolower(substitute(getcwd(), "/", "_", "g"))
    let cmd = "set tags=" . ctags_file_path
    echom cmd
    execute cmd
endfunction
"call CTags_PHP_generate()
"call CTags_lua_generate()

